#ifndef PARKDET_PROCESS__H
#define PARKDET_PROCESS__H

#include <cstdio>
#include <string>

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <sstream>
#include <ctime>
 
#include <iterator>
#include <memory>
#include <sstream>
#include <vector>

#include <openvino/openvino.hpp>

#include <opencv2/dnn.hpp>
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"

#include <unistd.h>
#include <sys/time.h>

#include <pthread.h>

#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"

#include "yolo.h"
#include "carInParkProc.h"

class ParkDetProc {

public:

    ParkDetProc();
    virtual ~ParkDetProc();

    void InitParkidStr(void);
    int GetParkid(int id);

    void checkStatus(void);

    int YoloParkDetFront(cv::Mat &img, int &number);
    int YoloParkDetBack(cv::Mat &img, int &number);

    void lock(void);
    bool trylock(void);
    void unlock(void);

    int status;//0: no use, 1: in use, 2:standby
    volatile int adjestStatus;//-1： ignore, 0~2 status
    char roadName[64];
    char startParkid[32];
    char endParkid[32];
    char weightPathFront[256];
    char weightPathBack[256];
    char classesidTxtPath[256];
    float fXInMapStart;
    float fYInMapStart;
    float fXInMapEnd;
    float fYInMapEnd;
    Yolo *pYoloFront;
    Yolo *pYoloBack;
    std::vector<int> parkClasses;

    pthread_mutex_t mutex;

private:

    int YoloParkDet(cv::Mat &img, int &number, Yolo *yolo);

};

#endif
